home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 March - Disc 1 / Macworld (1999-03) (Disk 1).dmg / Shareware World / Utilities / Text Processing / Alpha / LaTeX Docs / html.sty next >
Encoding:
Text File  |  1996-05-08  |  12.2 KB  |  360 lines  |  [TEXT/ALFA]

  1. % LaTeX2HTML Version 95.1 : html.sty
  2. %
  3. %  WARNING:  This file requires LaTeX2e.  A LaTeX 2.09 version
  4. %    is also provided, but with restricted functionality.
  5. %
  6. % This file contains definitions of LaTeX commands which are
  7. % processed in a special way by the translator. 
  8. % For example, there are commands for embedding external hypertext links,
  9. % for cross-references between documents or for including
  10. % raw HTML.
  11. % This file includes the comments.sty file v2.0 by Victor Eijkhout
  12. % In most cases these commands do nothing when processed by LaTeX.
  13.  
  14. % Modifications:
  15. %
  16. %  nd = Nikos Drakos <nikos@cbl.leeds.ac.uk>
  17. %  jz = Jelle van Zeijl <jvzeijl@isou17.estec.esa.nl>
  18. %  hs = Herb Swan <dprhws@edp.Arco.com>
  19.  
  20. % hs 31-JAN-96 - Added support for document segmentation
  21. % hs 10-OCT-95 - Added \htmlrule command
  22. % jz 22-APR-94 - Added support for htmlref
  23. % nd  - Created
  24. %%%%MG added
  25. \NeedsTeXFormat{LaTeX2e}
  26. \ProvidesPackage{html}
  27.           [1996/02/01 v1.0 hypertext commands for latex2html (nd, hs)]
  28. %%%%MG
  29. % Exit if the style file is already loaded
  30. % (suggested by Lee Shombert <las@potomac.wash.inmet.com>
  31. \ifx \htmlstyloaded\relax \endinput\else\let\htmlstyloaded\relax\fi
  32.  
  33. %%% LINKS TO EXTERNAL DOCUMENTS
  34. %
  35. % This can be used to provide links to arbitrary documents.
  36. % The first argumment should be the text that is going to be
  37. % highlighted and the second argument a URL.
  38. % The hyperlink will appear as a hyperlink in the HTML 
  39. % document and as a footnote in the dvi or ps files.
  40. %
  41. \newcommand{\htmladdnormallinkfoot}[2]{#1\footnote{#2}} 
  42.  
  43. % This is an alternative definition of the command above which
  44. % will ignore the URL in the dvi or ps files.
  45. \newcommand{\htmladdnormallink}[2]{#1}
  46.  
  47. % This command takes as argument a URL pointing to an image.
  48. % The image will be embedded in the HTML document but will
  49. % be ignored in the dvi and ps files.
  50. %
  51. \newcommand{\htmladdimg}[1]{}
  52.  
  53. %%% CROSS-REFERENCES BETWEEN (LOCAL OR REMOTE) DOCUMENTS
  54. %
  55. % This can be used to refer to symbolic labels in other Latex 
  56. % documents that have already been processed by the translator.
  57. % The arguments should be:
  58. % #1 : the URL to the directory containing the external document
  59. % #2 : the path to the labels.pl file of the external document.
  60. % If the external document lives on a remote machine then labels.pl 
  61. % must be copied on the local machine.
  62. %
  63. %e.g. \externallabels{http://cbl.leeds.ac.uk/nikos/WWW/doc/tex2html/latex2html}
  64. %                    {/usr/cblelca/nikos/tmp/labels.pl}
  65. % The arguments are ignored in the dvi and ps files.
  66. %
  67. \newcommand{\externallabels}[2]{}
  68.  
  69. %
  70. % This complements the \externallabels command above. The argument
  71. % should be a label defined in another latex document and will be
  72. % ignored in the dvi and ps files.
  73. %
  74. \newcommand{\externalref}[1]{}
  75.  
  76. % This command adds a horizontal rule and is valid even within
  77. % a figure caption.
  78. %
  79. \newcommand{\htmlrule}{}
  80.  
  81. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  82. %
  83. % The following commands pertain to document segmentation, and
  84. % were added by Herbert Swan <dprhws@edp.Arco.com> (with help from
  85. % Michel Goossens <goossens@cern.ch>):
  86. %
  87. %
  88. % This command inputs internal latex2html tables so that large
  89. % documents can to partitioned into smaller (more manageable)
  90. % segments.
  91. %
  92. \newcommand{\internal}[2][internals]{}
  93.  
  94. %
  95. %  Define a dummy stub \htmlhead{}.  This command causes latex2html
  96. %  to define the title of the start of a new segment.  It is not
  97. %  normally placed in the user's document.  Rather, it is passed to
  98. %  latex2html via a .ptr file written by \segment.
  99. %
  100. \newcommand{\htmlhead}[2]{}
  101.  
  102. %
  103. %  The dummy command \endpreamble is needed by latex2html to
  104. %  mark the end of the preamble in document segments that do
  105. %  not contain a \begin{document}
  106. %
  107. \newcommand{\startdocument}{}
  108.  
  109. %
  110. %  Allocate a new set of section counters, which will get incremented
  111. %  for "*" forms of sectioning commands, and for a few miscellaneous
  112. %  commands.
  113. %
  114.  
  115. \newcounter{lpart}
  116. \newcounter{lchapter}[part]
  117. \ifx\chapter\undefined\newcounter{lsection}[part]\else\newcounter{lsection}[chapter]\fi
  118. \newcounter{lsubsection}[section]
  119. \newcounter{lsubsubsection}[subsection]
  120. \newcounter{lparagraph}[subsubsection]
  121. \newcounter{lsubparagraph}[paragraph]
  122. \newcounter{lsubsubparagraph}[subparagraph]
  123. \newcounter{lequation}
  124. %
  125. %  Redefine "*" forms of sectioning commands to increment their
  126. %  respective counters.
  127. %
  128. \let\Hpart=\part
  129. \let\Hchapter=\chapter
  130. \let\Hsection=\section
  131. \let\Hsubsection=\subsection
  132. \let\Hsubsubsection=\subsubsection
  133. \let\Hparagraph=\paragraph
  134. \let\Hsubparagraph=\subparagraph
  135. \let\Hsubsubparagraph=\subsubparagraph
  136.  
  137. %
  138. %  The following definitions are specific to LaTeX2e:
  139. %  (They must be commented out for LaTeX 2.09)
  140. %
  141. \def\part{\@ifstar{\stepcounter{lpart}\Hpart*}{\Hpart}}
  142. \def\chapter{\@ifstar{\stepcounter{lchapter}\Hchapter*}{\Hchapter}}
  143. \def\section{\@ifstar{\stepcounter{lsection}\Hsection*}{\Hsection}}
  144. \def\subsection{\@ifstar{\stepcounter{lsubsection}\Hsubsection*}{\Hsubsection}}
  145. \def\subsubsection{\@ifstar{\stepcounter{lsubsubsection}\Hsubsubsection*}{\Hsubsubsection}}
  146. \def\paragraph{\@ifstar{\stepcounter{lparagraph}\Hparagraph*}{\Hparagraph}}
  147. \def\subparagraph{\@ifstar{\stepcounter{lsubparagraph}\Hsubparagraph*}{\Hsubparagraph}}
  148. \def\subsubparagraph{\@ifstar{\stepcounter{lsubsubparagraph}\Hsubsubparagraph*}{\Hsubsubparagraph}}
  149. %
  150. %  Define a helper macro to dump a single \secounter command to a file.
  151. %
  152. \newcommand{\DumpPtr}[2]{%
  153. \count255=\arabic{#1} \advance\count255 by \arabic{#2}
  154. \immediate\write\ptrfile{%
  155. \noexpand\setcounter{#1}{\number\count255}}}
  156.  
  157. %
  158. %  Define a helper macro to dump all counters to the file.
  159. %  The value for each counter will be the sum of the l-counter
  160. %      actual LaTeX section counter.
  161. %  Also dump an \htmlhead{section-command}{section title} command
  162. %      to the file.
  163. %
  164.  
  165. \def\DumpCounters#1#2#3{\newwrite\ptrfile
  166. \immediate\openout\ptrfile = #1.ptr
  167. \DumpPtr{part}{lpart}
  168. \ifx\Hchapter\undefined\relax\else\DumpPtr{chapter}{lchapter}\fi
  169. \DumpPtr{section}{lsection}
  170. \DumpPtr{subsection}{lsubsection}
  171. \DumpPtr{subsubsection}{lsubsubsection}
  172. \DumpPtr{paragraph}{lparagraph}
  173. \DumpPtr{subparagraph}{lsubparagraph}
  174. \DumpPtr{equation}{lequation}
  175. \immediate\write\ptrfile{\noexpand\htmlhead{#2}{#3}}
  176. \immediate\closeout\ptrfile}
  177.  
  178. %
  179. %  Define the \segment{file}{section-command}{section-title} command,
  180. %  and its helper macros.  This command does four things:
  181. %    1)  Begins a new LaTeX section;
  182. %    2)  Writes a list of section counters to file.ptr, each
  183. %        of which represents the sum of the LaTeX section
  184. %        counters, and the l-counters, defined above;
  185. %    3)  Write an \htmlhead{section-title} command to file.ptr;
  186. %    4)  Inputs file.tex.
  187. %
  188.  
  189. %%%%MG changed
  190. \def\segment{\@ifstar{\@@htmls}{\@@html}}
  191. \def\@@htmls#1#2#3{\csname #2\endcsname* {#3}%
  192.                    \DumpCounters{#1}{#2*}{#3}\input{#1}}
  193. \def\@@html#1#2#3{\csname #2\endcsname {#3}%
  194.                    \DumpCounters{#1}{#2}{#3}\input{#1}}
  195. %%%%MG 
  196.  
  197. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  198. % Comment.sty   version 2.0, 19 June 1992
  199. % selectively in/exclude pieces of text: the user can define new
  200. % comment versions, and each is controlled separately.
  201. % This style can be used with plain TeX or LaTeX, and probably
  202. % most other packages too.
  203. %
  204. % Examples of use in LaTeX and TeX follow \endinput
  205. %
  206. % Author
  207. %    Victor Eijkhout
  208. %    Department of Computer Science
  209. %    University Tennessee at Knoxville
  210. %    104 Ayres Hall
  211. %    Knoxville, TN 37996
  212. %    USA
  213. %
  214. %    eijkhout@cs.utk.edu
  215. %
  216. % Usage: all text included in between
  217. %    \comment ... \endcomment
  218. % or \begin{comment} ... \end{comment}
  219. % is discarded. The closing command should appear on a line
  220. % of its own. No starting spaces, nothing after it.
  221. % This environment should work with arbitrary amounts
  222. % of comment.
  223. %
  224. % Other 'comment' environments are defined by
  225. % and are selected/deselected with
  226. % \includecomment{versiona}
  227. % \excludecoment{versionb}
  228. %
  229. % These environments are used as
  230. % \versiona ... \endversiona
  231. % or \begin{versiona} ... \end{versiona}
  232. % with the closing command again on a line of its own.
  233. %
  234. % Basic approach:
  235. % to comment something out, scoop up  every line in verbatim mode
  236. % as macro argument, then throw it away.
  237. % For inclusions, both the opening and closing comands
  238. % are defined as noop
  239. %
  240. % Changed \next to \html@next to prevent clashes with other sty files
  241. % (mike@emn.fr)
  242. % Changed \html@next to \htmlnext so the \makeatletter and
  243. % \makeatother commands could be removed (they were causing other
  244. % style files - changebar.sty - to crash) (nikos@cbl.leeds.ac.uk)
  245. % Changed \htmlnext back to \html@next...
  246.  
  247. \makeatletter
  248. \def\makeinnocent#1{\catcode`#1=12 }
  249. \def\csarg#1#2{\expandafter#1\csname#2\endcsname}
  250.  
  251. \def\ThrowAwayComment#1{\begingroup
  252.     \def\CurrentComment{#1}%
  253.     \let\do\makeinnocent \dospecials
  254.     \makeinnocent\^^L% and whatever other special cases
  255.     \endlinechar`\^^M \catcode`\^^M=12 \xComment}
  256. {\catcode`\^^M=12 \endlinechar=-1 %
  257.  \gdef\xComment#1^^M{\def\test{#1}
  258.       \csarg\ifx{PlainEnd\CurrentComment Test}\test
  259.           \let\html@next\endgroup
  260.       \else \csarg\ifx{LaLaEnd\CurrentComment Test}\test
  261.             \edef\html@next{\endgroup\noexpand\end{\CurrentComment}}
  262.       \else \let\html@next\xComment
  263.       \fi \fi \html@next}
  264. }
  265. \makeatother
  266.  
  267. \def\includecomment
  268.  #1{\expandafter\def\csname#1\endcsname{}%
  269.     \expandafter\def\csname end#1\endcsname{}}
  270. \def\excludecomment
  271.  #1{\expandafter\def\csname#1\endcsname{\ThrowAwayComment{#1}}%
  272.     {\escapechar=-1\relax
  273.      \csarg\xdef{PlainEnd#1Test}{\string\\end#1}%
  274.      \csarg\xdef{LaLaEnd#1Test}{\string\\end\string\{#1\string\}}%
  275.     }}
  276.  
  277. \excludecomment{comment}
  278. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  279.  
  280. %%% RAW HTML 
  281. % Enclose raw HTML between a \begin{rawhtml} and \end{rawhtml}.
  282. % The html environment ignores its body
  283. %
  284. \excludecomment{rawhtml}
  285.  
  286. %%% HTML ONLY
  287. %
  288. % Enclose LaTeX constructs which will only appear in the 
  289. % HTML output and will be ignored by LaTeX with 
  290. % \begin{htmlonly} and \end{htmlonly}
  291. %
  292. \excludecomment{htmlonly}
  293. % Shorter version
  294. \newcommand{\html}[1]{}
  295.  
  296.  
  297. %%% LaTeX ONLY
  298. % Enclose LaTeX constructs which will only appear in the 
  299. % DVI output and will be ignored by latex2html with 
  300. %\begin{latexonly} and \end{latexonly}
  301. %
  302. \newenvironment{latexonly}{}{}
  303. % Shorter version
  304. \newcommand{\latex}[1]{#1}
  305.  
  306. %%% HYPERREF 
  307. % Suggested by Eric M. Carol <eric@ca.utoronto.utcc.enfm>
  308. % Similar to \ref but accepts conditional text. 
  309. % The first argument is HTML text which will become ``hyperized''
  310. % (underlined).
  311. % The second and third arguments are text which will appear only in the paper
  312. % version (DVI file), enclosing the fourth argument which is a reference to a label.
  313. %
  314. %e.g. \hyperref{using the tracer}{using the tracer (see Section}{)}{trace}
  315. % where there is a corresponding \label{trace}
  316. %
  317. \newcommand{\hyperref}[4]{#2\ref{#4}#3}
  318.  
  319. %%% HTMLREF
  320. % Reference in HTML version only.
  321. % Mix between \htmladdnormallink and \hyperref.
  322. % First arg is text for in both versions, second is label for use in HTML
  323. % version.
  324. \newcommand{\htmlref}[2]{#1}
  325.  
  326. %%% HTMLIMAGE
  327. % This command can be used inside any environment that is converted
  328. % into an inlined image (eg a "figure" environment) in order to change
  329. % the way the image will be translated. The argument of \htmlimage
  330. % is really a string of options separated by commas ie 
  331. % [scale=<scale factor>],[external],[thumbnail=<reduction factor>
  332. % The scale option allows control over the size of the final image.
  333. % The ``external'' option will cause the image not to be inlined 
  334. % (images are inlined by default). External images will be accessible
  335. % via a hypertext link. 
  336. % The ``thumbnail'' option will cause a small inlined image to be 
  337. % placed in the caption. The size of the thumbnail depends on the
  338. % reduction factor. The use of the ``thumbnail'' option implies
  339. % the ``external'' option.
  340. %
  341. % Example:
  342. % \htmlimage{scale=1.5,external,thumbnail=0.2}
  343. % will cause a small thumbnail image 1/5th of the original size to be
  344. % placed in the final document, pointing to an external image 1.5
  345. % times bigger than the original.
  346. \newcommand{\htmlimage}[1]{}
  347.  
  348. %%% HTMLADDTONAVIGATION
  349. % This command appends its argument to the buttons in the navigation
  350. % panel. It is ignored by LaTeX.
  351. %
  352. % Example:
  353. % \htmladdtonavigation{\htmladdnormallink
  354. %              {\htmladdimg{http://server/path/to/gif}}
  355. %              {http://server/path}}
  356. \newcommand{\htmladdtonavigation}[1]{}
  357.  
  358. \endinput